package com.juc.blockingqueue;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * @author yuanzheng
 * @date 2020/8/14-9:07
 */
public class Demo3 {
    public static void main(String[] args) throws InterruptedException {
        // 队列的大小
        ArrayBlockingQueue blockingQueue = new ArrayBlockingQueue<>(3);
        blockingQueue.put("a");
        blockingQueue.put("b");
        blockingQueue.put("c");
        //blockingQueue.put("d"); // 队列没有位置了，一直阻塞
        System.out.println(blockingQueue.take());
        System.out.println(blockingQueue.take());
        System.out.println(blockingQueue.take());
        //System.out.println(blockingQueue.take()); // 没有这个元素，一直阻塞
    }
}
